﻿<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<input type="hidden" id="cnum" value="${rcn}"/>
<script language="JavaScript" type="text/JavaScript">

function isImport(){
	alertMsg.confirm("确定要导入起始分区？导入后,该渠道原有起始分区将会被覆盖,该渠道原有起始分区关联的价格将会失效！", {
		okCall: function(){
			var myForm = document.getElementById("iform");
			myForm.onsubmit();
		}
	});
}

$(document).ready(function(){
    var cityn = document.getElementById("cnum").value;
    if(cityn == "hr"){
    	alert("有重复的城市！请检查后再导入！");
    }
    $("#addIPBtn").click(function(){
    	$.ajax({
    	type: "post",
    	url: "<%=basePath%>partition_addSPartition.action", 
    	data: $("#iform").serialize(),
    	success: function(msg){
    		$("#StartPartitionList").html("");
    		$("#StartPartitionList").html(msg);
    	} //操作成功后的操作！msg是后台传过来的值  
    	});
    });
    
    
    
  
    
	});
	

function delIPBtn(p_num){
    	$.ajax({
    	type: "post",
    	url: "<%=basePath%>partition_delSPartition.action?p_num="+p_num, 
    	data: $("#iform").serialize(),
    	success: function(msg){
    		$("#StartPartitionList").html("");
    		$("#StartPartitionList").html(msg);
    	} //操作成功后的操作！msg是后台传过来的值  
    	});
  }
</script>

<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<!-- <li><button id="addIPBtn">添加分区</button> </li> 
			<li><a class="add" href="/EServer/partition_getChannelBean.action?isPD=EPD" target="navTab" title="导入起始分区"
			rel="ImportStartPartition"><span>导入起始分区</span></a></li>
			-->
			<li><a title=""  class="edit"
			href="<%=basePath%>partition_check_S_Partition.action?pChannel_number=${pChannel_number}&partitionClass=ST" target="navTab" rel="StartPartitionTable"><span>查看起始分区</span></a></li>
			<li class="line">line</li>
			<li><a class="icon" href="demo/common/dwz-team.xls" target="dwzExport" targetType="navTab" title="是要导出分区表吗?"><span>导出分区表</span></a></li>
			<li><a class="icon" href="demo/common/dwz-team.xls" target="dwzExport" targetType="navTab" title="是要检查分区表吗?"><span>检查分区表</span></a></li>
		</ul>
	</div>
	<div class="divider"></div>
	<form id="iform" method="post" action="<%=basePath%>partition_saveISPartition.action?isCityTree=yes" class="pageForm required-validate" onsubmit="return validateCallback(this,navTabAjaxDone)">
	<input type="hidden" name="partitionClass" value="ST"/>
	<input type="hidden" name="Dizhi" value="pricemanager/Channel/EditStartPartition.jsp"/>
	<label>&nbsp;&nbsp;渠道名称i：</label>
			<input id="pnchan" name="pChannel_number" type="hidden" value="${pChannel_number}" />
			<input name="pChannelABean.channel.PChannelName" class="required" type="text" size="30" value="${pChannelABean.channel.PChannelName}"  readonly="true"/>
	<div class="divider"></div>
	<div id="StartPartitionList" layoutH="108">
	<table>
			<tr>
				<td><label class="contentTitle" style="font-size: 14; color: blue;">分区号:↓</label></td>
				<td><label class="contentTitle" style="font-size: 14; color: blue;">分区名:↓</label></td>
				<td><label class="contentTitle" style="font-size: 14; color: blue;">起始地:↓</label></td>
				<td><label class="contentTitle" style="font-size: 14; color: blue;">起始地:↓</label></td>
			</tr>
			
			<c:forEach items="${IPartition}" var="partition">
				<tr target="sid_user" rel="1">
				<td width="130">
					<input name="i_partition_num" class="required" type="text" size="18" value="${partition.PPartitionNumber }" readonly="readonly"/>
					<c:forEach items="${repeatPartitionNumber}" var="rPNum">
						<c:if test="${partition.PPartitionNumber == rPNum}">
							<font color="red">已存在或重复</font>
						</c:if>
					</c:forEach>
				</td>
				<td width="130">
					<input name="i_partition_name" class="required" type="text" size="18" value="${partition.PPartitionName }"/>
					<c:forEach items="${repeatPartitionName}" var="rPName">
						<c:if test="${partition.PPartitionName == rPName}">
							<font color="red">已存在或重复</font>
						</c:if>
					</c:forEach>
				</td>
				<td width="320">
					<textarea readonly="readonly" name="i_partition_city_name" class="required" cols="40" rows="6"><c:forEach items="${iPartitionLine}" var="partitionLine"><c:if test="${partition.PPartitionNumber ==partitionLine.PPartitionNumber }">${partitionLine.clinentCityName },</c:if></c:forEach></textarea>
					<div style="display: none;">
					<textarea id="${partition.PPartitionNumber }" name="i_partition_city_num" cols="25" rows="6"><c:forEach items="${iPartitionLine}" var="partitionLine"><c:if test="${partition.PPartitionNumber ==partitionLine.PPartitionNumber }">${partitionLine.clientCityNumber },</c:if></c:forEach></textarea>
					</div>
				</td>
				<td width="50">
					<a target="dialog" width="440" height="460" href="<%=basePath%>partition_findCity.action?p_Number=${partition.PPartitionNumber }" class="btnEdit" rel="CityTree">起始地</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				</td>
				<!--  
				<td width="50">
				<button onclick="delIPBtn('${partition.PPartitionNumber }')">删除分区</button>
				</td>
				-->
			</tr>
			</c:forEach>
	</table>
	</div>
	<div class="formBar">
			<ul>
				<!--<li><a class="buttonActive" href="javascript:;"><span>保存</span></a></li>-->
				<li><div class="buttonActive"><div class="buttonContent"><button onclick="isImport()" type="button">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
 </form>	
</div>
